if(1)
  N = 128;

  h = (1/N);
  V = 1 + rand(N,N);

  global Tree;
  global mvcount
  disp('Factorization');
  Tree = five_setup(V,N,h);
  disp('Extraction');
  DiagExact = five_extract(N,Tree);
  DiagExact = reshape( DiagExact, N*N, 1 );
end

global svdcase

if(1)
    svdcase = 1;
    nLevel = 1;
    mvcount = 0;


    [DiagBlock, SampleList, RKTree, nDiagBlock] = ConstructHMatrix( N, nLevel );
    nSample = 20;
    u = rand(N,N,nSample);
    v1 = WholeTreeApply( ...
      RKTree, DiagBlock, u, N, nSample, nLevel+1, nDiagBlock);
    v2 = KernelApply( N, reshape(u, N*N, nSample) );
    err = mean( sqrt(sum((v1-v2).^2,1)) ./ sqrt(sum(v1.^2,1)) )
end
